class Photo < ActiveRecord::Base
  belongs_to :user
  belongs_to :retype,
             :class_name => "Retype",
             :foreign_key => 'retype_id'

  has_attached_file :pic, :styles => {  :thumb =>  { :geometry => "250x250>",
#                                                      :watermark_path => "#{RAILS_ROOT}/public/images/watermark125.png",
                                                      :position => "SouthEast"},
                                        :resized => { :geometry => "500x500>",
#                                                      :watermark_path => "#{RAILS_ROOT}/public/images/watermark250.png",
                                                      :position => "SouthEast"}
                                     },
#                          :processors => [:watermark],
                          :path => ":rails_root/public/:class/:attachment/:id/:style_:basename.:extension",
                          :url  => "/:class/:attachment/:id/:style_:basename.:extension"
  attr_protected :pic_file_name, :pic_file_size, :pic_content_type
  validates_presence_of :title, :message=> "不能为空"
  validates_attachment_presence :pic, :message => "请上传您的图片"
  validates_attachment_size :pic, :less_than => 5.megabytes, :message => "图片不超过5m"
  validates_attachment_content_type :pic, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg'  ,'image/png','image/bmp','image/gif'], :message => "请上传图像文件"
  
end
